package com.bharat.web.managedBeans;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import com.bharat.domain.Patient;
import com.bharat.services.PatientService;

public class PatientTestManagedBean implements Serializable{
	
	private static final long serialVersionUID = 2451L;
	private final Logger log = Logger.getLogger(PatientTestManagedBean.class); 
	
	private Patient patient;
	
	private List<Patient> patients;
	
	private PatientService patientService;
	
	
	public void setPatient(Patient patient) {
		this.patient = patient;
	}
	
	public Patient getPatient() {
		return patient;
	}
	
	public List<Patient> getPatients() {
		return patients;
	}
	
	public void setPatients(List<Patient> patients) {
		this.patients = patients;
	}
	
	public void setPatientService(PatientService patientService) {
		this.patientService = patientService;
	}

	// default constructor
	public PatientTestManagedBean() {
		patient = new Patient();
		patients = new ArrayList<Patient>();
	}
	
	public void savePatient(){
		log.info("Patient: "+ patient);
		this.patientService.createPatient(patient);
	}
	
	public List<Patient> getAllPatients(){
		this.patients = this.patientService.getAllPatients();
		return this.patients;
	}
}
